Skip to content

Conversation

erindru
Copy link
Collaborator

@erindru erindru commented Aug 21, 2025

Adds the --select and --exclude arguments to the sqlmesh_dbt run and sqlmesh_dbt list commands (the list command is mainly for testing expressions).

This is implemented in terms of generating a complex selection targeting the SQLMesh selector engine rather than attempting to re-implement a new selector engine from scratch.

  • dbt set unions eg model_a model_b are translated to |
  • dbt set intersections eg model_a,model_b are translated to &
  • --exclude is implemented in terms of using negation ^ on each expression and then doing a set intersection with whatever was supplied for --select

The selectors are still matched against model names, which differ between dbt and sqlmesh.

For example, on jaffle shop, the following selector works in dbt:
dbt list --select customers (selects the jaffle_shop.customers model)

However, on the SQLMesh selector engine it will return nothing, it needs to be:
sqlmesh_dbt list --select main.customers

I intend to address this in a follow-up PR if the groundwork laid in this PR is considered a suitable direction

@erindru erindru marked this pull request as draft August 21, 2025 22:12
@erindru erindru force-pushed the erin/dbt-selectors branch from 0f90cd8 to 5995209 Compare August 22, 2025 02:58
@erindru erindru marked this pull request as ready for review August 22, 2025 03:39
@erindru erindru force-pushed the erin/dbt-selectors branch from 5995209 to bf9dad5 Compare August 22, 2025 03:51
@erindru erindru merged commit 4fc3ba6 into main Aug 24, 2025
28 checks passed
@erindru erindru deleted the erin/dbt-selectors branch August 24, 2025 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants